<?php
namespace app\common\controller;
use data\cache\CacheToken;
use app\BaseController;
use think\App;
use think\model;


class DBase extends BaseController
{
    protected $api_result;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->api_result = new ApiResult();
    }

    public function jsonMessage( $code = 200, $success = false, $msg = "加载错误", $data = []){
        $this->api_result->code = $code;
        $this->api_result->success = $success;
        $this->api_result->msg = $msg;
        $this->api_result->data = [];
        if($data)  $this->api_result->data = $data;
        if ($this->api_result) {
            return json($this->api_result);
        } else {
            abort(404);
        }
    }

}

